<template>
  <div class="sidebar">
    <el-menu :default-active="onRoutes" class="el-menu-vertical-demo" theme="dark" unique-opened router>
      <template v-for="(item, key) in items">
        <template v-if="item.children">
          <el-submenu :index="item.text" :key="key">
            <template slot="title">
              <!-- <i :class="item.icon"></i> -->{{ item.text }}</template>
            <el-menu-item v-for="(subItem,i) in item.children" :key="i" :index="subItem.url">{{ subItem.text }}
            </el-menu-item>
          </el-submenu>
        </template>
        <template v-else>
          <el-menu-item :index="item.text" :key="key">
            <!-- <i :class="item.icon"></i> -->{{ item.text }}
          </el-menu-item>
        </template>
      </template>
    </el-menu>
  </div>
</template>
<script>
import {
  getMenuList
}
  from '@/services/getData'
export default {
  data() {
    return {
      items: []
    }
  },
  mounted() {
    this.initData();
  },
  computed: {
    onRoutes() {
      return this.$route.path.replace('/', '');
    }
  },
  methods: {
    async initData() {
      let menuResList = JSON.parse(sessionStorage._router_userInfo_).menuResList
      this.items = menuResList
    }
  }
}
</script>
<style scoped>
.sidebar {
  display: block;
  position: absolute;
  width: 250px;
  left: 0;
  top: 70px;
  bottom: 0;
  background: #2e363f;
}

.sidebar > ul {
  height: 100%;
  overflow-y: auto;
}
</style>
